<%@ page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@page import="java.net.URL"%>
<%@page import="org.springframework.web.context.WebApplicationContext" %>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<html>
<head>
<title>登录</title>
<!-- ExtJS -->
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/public/extjs/resources/css/ext-all.css" />
<link href="<%=request.getContextPath()%>/public/style/default/css/login.css" rel="stylesheet" type="text/css">
<script type="text/javascript"
	src="<%=request.getContextPath()%>/public/extjs/ext-all.js"></script>
	<script type="text/javascript"	src="<%=request.getContextPath()%>/public/include/js/component.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/public/include/js/api/appdeal.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/public/include/js/md5.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/public/js/jquery-1.9.1.min.js"></script>


<!-- GC 33-->
<%
//out.println("dddddddddeeeeeeee");

//已有登录用户,直接转到登录后主界面
//VoSysrightRcAccounts user = (VoSysrightRcAccounts)httpRequest.getSession().getAttribute("UserView");
//if(user != null && user.getUuid() != null){
//	response.sendRedirect("mainFrame.do?action=showOpenMainFrame");
//}
%>

<style>
#loginmain{
float:left;
/*margin:25px 0 0 40px;*/
width:850px;
height:563px;
background:url('<%=request.getContextPath()%>/public/style/default/image/login/login2.jpg') #fff no-repeat center;
border:solid red 0px;
/*居中*/
position: absolute;
}
#log{
float:right;
margin-right:50px;
margin-top:265px;}
select{
    background: #FFFFFF;
    border: 1px solid #999;
    color: #000000;
    font-family: verdana, tahoma, sans-serif;
    font-size: 0.95em;
	height: 19px;
}
.kuang{
    padding-left:5px;
	height:18px;
	FONT-SIZE: 12px;}
</style>

</head>
<body onload="setWinLocation()" onResize = "setWinLocation()">
<div style="border:solid green 0px; height:100%">
<%//String disp_or_hide = "display:";%>
<div align=center id="pwdlogin" style=<%//=disp_or_hide%>></div>
<%--<div align=left class="kuang" id="errorinfo"><html:errors/></div> /去掉登录不成功时的提示--%>

<div id="loginmain">
<div id="log">

<table width="344" border="0" align="center" cellpadding="1" cellspacing="0">
  <!-- <tr align="center" height="30">
    <td ><font size="2">单 位：</font></td>
    <td align="left" valign="center">
    <select NAME="Department" style="width:173px;font-size: 0.75em;" onkeydown="f_checkKey(event)">
    </select>
    </td>
  </tr> -->
  <tr align="center" height="30">
    <td><font size="2">用 户：</font></td>
    <td align="left" valign="center">
<div style='position:absolute;clip:rect(auto auto auto 155); width:173;'>
    <select name="username" id="username" style="width:100%;"  onchange="txtname.value=this.options[this.selectedIndex].value" onkeydown="checkKey(event)">
    <option value="" ></option>
	<%
	
	%>
    </select> 
</div><input type=text name="txtname" id="txtname"  onblur="document.forms[0].username.options[0].selected=true;document.forms[0].username.options[0].value=this.value" style='position:relative;width:156.5;height:19px;' onkeydown="checkKey(event)">
</td>
    </tr>  
  <tr align="center" height="30">
    <td><font size="2">密 码：</font></td>
    <td align="left"><input name="password" id="password" type="password" class="kuang" style="width:173" onkeydown="checkKey(event)" value=""></td>
    <td></td>
  </tr>
  
  
 

</table>
<br>
	<input type="button" value="登录" onclick="f_login()" onkeyup="keyup()" style='size: 4px;position:relative;width:50;height:25;top:0;left:120;'>
  	<input type="reset" value="重填" style='size: 4px;position:relative;width:50;height:25;top:0;left:130;'>

</div>
</body>
<script language="javascript">
	/* var html = "";
	Ext.Ajax.request({
		url : "common.do?action=getDeptInfoByDeptRole",
		params : {
			deptRoleId : 'SYSRIGHTDEPT'
		},
		method : "POST",
		success : function(response) {
			var list = Ext.JSON.decode(response.responseText);
			for(var i=0;i<list.length;i++){
				var obj = list[i];
				if(i==0) html = "<option value="+obj.uuid+" selected>"+obj.deptName+"</option>";
				else html += "<option value="+obj.uuid+">"+obj.deptName+"</option>";
			}
			document.getElementsByName("Department")[0].innerHTML = html;
		},
		failure : function() {
			//Ext.Msg.alert("错误", "与后台联系的时候出现了问题");
		}
	}); */
	
	function isOsSubmit(){
		return navigator.userAgent.indexOf("Firefox")>0;
	}
	//alert(navigator.userAgent.indexOf("Safari")>0);
	function setWinLocation(){
		var bodywidth = document.body.clientWidth;
		var bodyheight = document.body.clientHeight;
		var top1 = document.getElementById("loginmain").offsetTop;
		var left1 = document.getElementById("loginmain").offsetLeft;
		var lwidth = document.getElementById("loginmain").offsetWidth;
		var lheight = document.getElementById("loginmain").offsetHeight;
		top1 = (bodyheight-lheight)/2;
		left1 = (bodywidth-lwidth)/2;
		document.getElementById("loginmain").style.top = top1;
		document.getElementById("loginmain").style.left = left1;
	}
	
	function checkKey(event){
		var explorer = window.navigator.userAgent ;
		event = event || window.event;
		var keycode = event.keyCode||event.which||event.charCode;
		//ie 
		/* if (explorer.indexOf("MSIE") >= 0) {
			keycode = event.keyCode;
		}
		//firefox 
		else if (explorer.indexOf("Firefox") >= 0) {
			
			keycode = event.keyCode||event.which||event.charCode;
		}
		//Chrome
		else if(explorer.indexOf("Chrome") >= 0){
			keycode = event.keyCode;
		}else{
			
		} */
		if(keycode == 13){
			f_login();
		}
	}
	
	function f_login(){
		/* if(!isOsSubmit()){
			//alert("请使用火狐浏览器登录系统！");
			Ext.Msg.alert("提示信息", "请使用火狐浏览器登录系统！");
			return ;
		} */
		var loginname = document.getElementById("txtname").value;
		if(loginname == null || loginname == ""){
			alert("请输入用户名！");
			return;
		}
		var password = document.getElementById("password").value;
		if(password == null || password == ""){
			alert("请输入密码！");
			return;
		}
		
		//var departmentId = document.forms[0].Department.value;	
		var host=window.location.host;
		
		
		var aft_pas = "";
		var ber_nam = loginname;
		var url = '<%=request.getContextPath()%>/getYsEncrypted.do';
		var continueF=false;
		$.ajax({
            //请求方式
            type : "POST",
            //请求的媒体类型
            //contentType: "application/json;charset=UTF-8",
            dataType:"json",
            async:false,
            traditional: true,
            //请求地址
            url : url,
            //数据，json字符串
            data : {"encryptionPamar":"1","time":(new Date()).getTime()},
            //请求成功
            success : function(result) { 
            	window.open("mainframe.jsp", "_self");
            	aft_pas = result.data[0];
            	continueF= true;
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                //console.log(e.status);
                //console.log(e.responseText);
                //alert(e.responseText);
                window.open("mainframe.jsp", "_self");
            }            
        });
		
	}

	window.onload=function(){		
		setWinLocation();
	}

	
</script>
</html>